<!--
 * @FilePath     : /study_code/layui/20-10.html
 * @Description  : laypage 将一段已知数组分页展示
 * @Date         : 2025-04-15 09:46:59
 * @Author       : Fang YingGui
 * @LastEditors  : fangyinggui 18715384437@163.com
 * @LastEditTime : 2025-04-15 09:47:35
-->
<!--
 * @FilePath     : /study_code/layui/20-9.html
 * @Description  : laypage 开启 HASH
 * @Date         : 2025-04-15 09:45:49
 * @Author       : Fang YingGui
 * @LastEditors  : fangyinggui 18715384437@163.com
 * @LastEditTime : 2025-04-15 09:45:56
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>documentName</title>
    <link rel="stylesheet" href="/layui/dist/css/layui.css" />
  </head>
  <body>
    <div id="demo-laypage-data"></div>
    <div id="demo-laypage-data-view"></div>

    <script src="/layui/dist/layui.js"></script>
    <script>
      layui.use(['laypage'], function () {
        var laypage = layui.laypage

        // 将一段已知数组分页展示
        var data = [
          '北京',
          '上海',
          '广州',
          '深圳',
          '杭州',
          '长沙',
          '合肥',
          '宁夏',
          '成都',
          '西安',
          '南昌',
          '上饶',
          '沈阳',
          '济南',
          '厦门',
          '福州',
          '九江',
          '宜春',
          '赣州',
          '宁波',
          '绍兴',
          '无锡',
          '苏州',
          '徐州',
          '东莞',
          '佛山',
          '中山',
          '成都',
          '武汉',
          '青岛',
          '天津',
          '重庆',
          '南京',
          '九江',
          '香港',
          '澳门',
          '台北',
        ] // 测试数据
        laypage.render({
          elem: 'demo-laypage-data',
          count: data.length,
          jump: function (obj) {
            // 模拟渲染
            document.getElementById('demo-laypage-data-view').innerHTML = (function () {
              var arr = []
              var thisData = data.concat().splice(obj.curr * obj.limit - obj.limit, obj.limit)
              layui.each(thisData, function (index, item) {
                arr.push(item)
              })
              return arr.join('，')
            })()
          },
        })
      })
    </script>
  </body>
</html>
